<template>
  <div>
    <div class="row">
      <div v-for="column in colunmList" :key="column.id" class="col-4 mb-4">
        <div class="card h-100 shadow-sm">
          <div class="card-body">
            <img
              :src="column.avatar"
              :alt="column.title"
              class="rounded-circle border border-light w-25 my-3"
            />
            <h5 class="card-title">{{ column.title }}</h5>
            <p class="card-text text-left">{{ column.descrtption }}</p>
            <a href="#" class="btn btn-outline-primary">进入专栏</a>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts">
import { computed, defineComponent, PropType } from 'vue'
export interface ColumnProps {
  id: number;
  title: string;
  avatar?: string;
  descrtption: string;
}

export default defineComponent({
  name: 'ColumList',
  props: {
    list: {
      type: Array as PropType<ColumnProps[]>,
      required: true
    }
  },
  setup (props) {
    const colunmList = computed(() => {
      return props.list.map(colunm => {
        if (!colunm.avatar) {
          colunm.avatar = require('@/assets/logo.png')
        }
        return colunm
      })
    })
    return {
      colunmList
    }
  }
})
</script>

<style></style>
